package org.pp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 商品订单表
 * </p>
 *
 * @author haima
 * @since 2024-10-07
 */
@Getter
@Setter
@TableName(value = "pp_order",autoResultMap = true)
@Schema(name = "PpOrder", description = "商品订单表")
public class PpOrder implements Serializable {

    private static final long serialVersionUID = 1L;

    @Setter
    @Getter
    public static class PostAddress{

        @Schema(description = "完整地址")
        private String location;

        @Schema(description = "手机号")
        private String phone;

        @Schema(description = "收件人姓名")
        private String name;
    }

    @Setter
    @Getter
    public static  class ItemInfo{
        @Schema(description = "商品名称")
        private String name;

        @Schema(description = "sku封面图")
        private String cover;

        @Schema(description = "售价")
        private BigDecimal price;

        @Schema(description = "选择的属性值拼接")
        @TableField(exist = false)
        private String attrInfoStr;

        @Schema(description = "购买数量")
        private Integer amount;

        @Schema(description = "商品总价（售价乘以数量，感觉冗余)")
        private BigDecimal totallPrice;

        @Schema(description = "邮费")
        private BigDecimal totallPostage;

        @Schema(description = "邮费说明")
        private String totallPostageDesc;

    }

    @Schema(description = "订单id")
    @TableId(value = "order_id", type = IdType.AUTO)
    private Long orderId;

    @Schema(description = "用户id")
    private Long userId;

    @Schema(description = "商品名称，冗余，用于搜索")
    private String names;

    @Schema(description = "条目信息")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private ItemInfo[] itemInfo;

    @Schema(description = "商品总价")
    private BigDecimal goodsPrice;

    @Schema(description = "邮费")
    private BigDecimal postage;

    @Schema(description = "支付金额")
    private BigDecimal payPrice;

    @Schema(description = "用户留言")
    private String userMsg;

    @Schema(description = "订单号")
    private String orderNo;

    @Schema(description = "交易号")
    private String tradeNo;

    @Schema(description = "商品数")
    private Integer amount;

    @Schema(description = "订单状态 -1已取消 0 待支付 1待发货 2待收货 3待评价 4已评价")
    private Integer status;

    @Schema(description = "支付时间")
    private LocalDateTime payedTime;

    @Schema(description = "支付通道 0微信支付")
    private Integer payChannel;

    @Schema(description = "邮寄轨迹")
    private String postTrace;

    @Schema(description = "邮寄地址记录")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private PostAddress postAddress;

    @Schema(description = "租户号")
    private Long tenantId;

    @Schema(description = "乐观锁")
    private Integer revision;

    @Schema(description = "创建时间")
    private LocalDateTime createdTime;

    @Schema(description = "更新时间")
    private LocalDateTime updatedTime;

    @Schema(description = "逻辑删除 1为删除 0为正常")
    private Boolean deleted;
}
